/* This file is part of FireEscape.
 *
 * FireEscape is the intellectual work of Phillip Cheng & Allen Park.
 * All future releases or modifications of this program must include this
 * attribuation as according to the Creative Commons BY-SA license.
 *
 * FireEscape is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * FireEscape is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with FireEscape.  If not, see <http://www.gnu.org/licenses/>.
 *
 * All modifications to this program should include this original statement.
 *
 * If you modify, distribute, or use the program , please contact
 * fireescape@kloudvine.com
 * http://code.google.com/p/fireescape/
 *
 * If you are interested in using FireEscape for your structure, please contact us
 * for support.
 *
 * If you do use FireEscape, please consider donating to the project.
 */
package fireescape;

import java.awt.*;
import java.util.logging.*;

/**
 * The main object
 * @author chengP
 */
public class FireEscape {

    //private final double xSize;
    //private final double ySize;
    public static int escapeCount;
    public static int deathCount;

    /**
     * Constructs the object
     * @param xSize The new x size
     * @param ySize The new y size
     */
    public FireEscape(double xSize, double ySize) {
        escapeCount = 0;
        deathCount = 0;
        //this.xSize = xSize;
        //this.ySize = ySize;
        new Map(xSize, ySize);
        new BotAI();
        if (BotAI.defaultDistance > BotAI.botRadius * 2) {
            Logger.getLogger("FireEscapeLog").log(Level.SEVERE, "WARNING: default distance is greater than the bot diameter.");
        }
    }

    /**
     * Starts the program
     */
    public void start() {
        Map.init();
        Client.initialize();
        GeneticAI.init();
    }

    /**
     * Paints everything
     * @param g The Graphics2D object
     * @param floorNum The floor number to be painted
     */
    public void paint(Graphics2D g, int num) {
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
        if (!FireEscapeGUI.stairOutput) {
            Map.paint(g, num);
        } else {
            Map.getStaircase(num).drawStaircase(g);
        }
        GeneticAI.paint(g);
    }

    /**
     * Runs the genetic AI
     */
    public void run() {
        GeneticAI.run();
    }
}
